// components/authorization/index.js
Component({
  data: {
    isLogin: false
  },
  lifetimes: {
    attached () {
      const route = getCurrentPages().pop().route
      const isLogin = !!getApp().token //有就是对
      const pageStack = getCurrentPages()
      const currentPage = pageStack.pop()
      if (!isLogin) {
        currentPage.onLoad = () => {}
        currentPage.onShow = () => {}
        wx.redirectTo({
          url: '/pages/login/index?route=' + route
        })
      }
      this.setData({ isLogin })
    }
  }
})
